#include "ModRunBridge.h"
#include <QDebug>

#include "../Output/FactoryOutput.h"

#include "Gof23/Gof_Bridge/PriceSmall.h"
#include "Gof23/Gof_Bridge/PriceBig.h"
#include "Gof23/Gof_Bridge/CompanyHuawei.h"
#include "Gof23/Gof_Bridge/CompanyMi.h"
#include "Gof23/Gof_Bridge/CompanyZTE.h"
#include "Gof23/Gof_Bridge/ComputerLaptop.h"
#include "Gof23/Gof_Bridge/ComputerPad.h"
#include "Gof23/Gof_Bridge/ComputerPC.h"
#include "Gof23/Gof_Bridge/ProductComputer.h"

//桥接模式的ModRun（Bridge）;
ModRunBridge::ModRunBridge()
{
    //模式名称;
    m_strModelName = "桥接模式（Bridge）;";
    //模式描述;
    m_strModelDesc = "桥接模式:当要构建一类事物时，这类事物从不同维度有不同分支，增可以考虑通过维度将事物进行抽象\n"
                     "这样就可以通过组合的方式，实现此类事物的不同实现\n"
                     "\n"
                     ;
}

//初始化显示模式;
void ModRunBridge::InitDisplay()
{
    qDebug() << m_strModelName;
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateDescOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outList{ m_strModelName,m_strModelDesc};
        pOutPut->OutPut(outList);
    }
}

//返回模式类型;
EnumModRun ModRunBridge::GetEnum()
{
    return emModRunBridge;
}

//运行模式;
void ModRunBridge::ModRun()
{
    std::shared_ptr<IOutput> pOutPut = FactoryOutput::GetInstance()->CreateRunOutput();
    if (pOutPut)
    {
        std::initializer_list<QString> outListStart{ "========桥接模式 start:=======" };
        std::initializer_list<QString> outListEnd{ "========桥接模式 end:=======" };
        pOutPut->OutPut(outListStart);

        //桥接模式;
        ///////////////////////////////////////////////////////////
        // 折扣维度;
        //小活动;
        std::shared_ptr<PriceSmall> priceSmall(new PriceSmall());
        //大促销;
        std::shared_ptr<PriceBig> priceBig(new PriceBig());

        ///////////////////////////////////////////////////////////
        // 电脑类型维度;
        //台式电脑;
        std::shared_ptr<ComputerPC> computerPC(new ComputerPC());
        //笔记本电脑;
        std::shared_ptr<ComputerLaptop> computerLaptop(new ComputerLaptop());
        //Pad;
        std::shared_ptr<ComputerPad> computerPad(new ComputerPad());

        //////////////////////////////////////////////////////////////
        //公司维度;
        //华为公司;
        std::shared_ptr<CompanyHuawei> companyHuawei(new CompanyHuawei());
        //中兴公司;
        std::shared_ptr<CompanyZTE> companyZTE(new CompanyZTE());
        //小米公司;
        std::shared_ptr<CompanyMi> companyMi(new CompanyMi());


        //销售电脑产品，华为,笔记本，小活动;
        std::shared_ptr<ProductComputer> productComputerHuawei(new ProductComputer(companyHuawei, computerLaptop, priceSmall));
        productComputerHuawei->ProductSale();

        //销售电脑产品，小米,台式机，大促销;
        std::shared_ptr<ProductComputer> productComputerMi(new ProductComputer(companyMi, computerPC, priceBig));
        productComputerMi->ProductSale();

        //销售电脑产品，中兴,Pad，大促销;
        std::shared_ptr<ProductComputer> productComputerZTE(new ProductComputer(companyZTE, computerPad, priceBig));
        productComputerZTE->ProductSale();

        pOutPut->OutPut(outListEnd);
    }

}

InterFaceModRun* ModRunBridge::CreateMe()
{
    return new ModRunBridge();
}
